import axios from 'axios'
import {
    CHANGE_LOGIN,
    CHANGE_LOGOUT
} from './types'

const changeLogin = () => ({
    type: CHANGE_LOGIN,
    value: true
})

export const logOuts = ()=>({
    type: CHANGE_LOGOUT,
    value: false
})

export const login = (accout, password) => {
    return (dispatch) => {
        axios.get('/api/login.json?accout=' + accout + '&password=' + password)
            .then(res => {
                const result = res.data.data
                if (result) {
                    dispatch(changeLogin())
                } else {
                    alert('登陆失败')
                }
            })
    }
}
